#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
'''
文件名称：main.py
描    述：
'''

class Solution:
    """
    @param str: the pattern
    @return: the minimum number
    """
    def form_minimum_number(self, strs: str) -> str:
        ans = [0 for _ in range(len(strs) + 1)]
        strlen = len(strs)
        count = 1
        for i in range(strlen + 1):
            if i == strlen or strs[i] == 'I':
                for j in range(i - 1, -2, -1):
                    ans[j + 1] = count
                    count += 1
                    if j >= 0 and strs[j] == 'I':
                        break

        return "".join([str(x) for x in ans])

if __name__ == "__main__":
    solution = Solution()
    print(solution.form_minimum_number("DDIDDIID"))
